#include<bits/stdc++.h>
#define LL long long
#define LLL __int128
#define uint unsigned
#define ldb long double
#define uLL unsigned long long
using namespace std;
const int N=5e5+5;
int n,m,q,fd[N],pos[N];
vector<int>S[N*4],T[N*4];
tuple<int,int,int,int>Q[N];
inline bool chk(const int&x,const int&y){
	const auto [lx,rx,dx,ux]=Q[x];
	const auto [ly,ry,dy,uy]=Q[y];
	return (ly!=rx||dy!=ux)&&(ly!=rx||dy!=ux-1)&&(ly!=rx-1||dy!=ux)&&(ry!=lx||dy!=ux)&&(ry!=lx||dy!=ux+1)&&(ry!=lx+1||dy!=ux);
}
inline int find(const int&x){return fd[x]==x?x:fd[x]=find(fd[x]);}
inline void merge(int x,int y){
	fd[x]=y;
	const auto [lx,rx,dx,ux]=Q[x];const auto [ly,ry,dy,uy]=Q[y];
	Q[y]=make_tuple(min(lx,ly),max(rx,ry),min(dx,dy),max(ux,uy));
}
inline bool solve(int id,vector<int>&S){
	int o=0;
	vector<int>cur;
	while(!S.empty()){
		const int x=S.back();
		if(x!=find(x)||find(x)==find(id))S.pop_back();
		else if(get<3>(Q[x])<get<2>(Q[id]))break;
		else if(chk(x,id))merge(x,id),o=1,S.pop_back();
		else cur.emplace_back(x),S.pop_back();
	}
	while(!cur.empty())S.emplace_back(cur.back()),cur.pop_back();
	return o;
}
inline void build(int p,int l,int r){
	if(l==r)return pos[l]=p,void();
	const int mid=(l+r)>>1,ls=p*2,rs=p*2+1;
	build(ls,l,mid),build(rs,mid+1,r);
}
inline void upd(int p,int l,int r,int x,int y,int z){
	if(x<=l&&r<=y)return T[p].emplace_back(z),void();
	const int mid=(l+r)>>1,ls=p*2,rs=p*2+1;
	if(x<=mid)upd(ls,l,mid,x,y,z);
	if(mid<y)upd(rs,mid+1,r,x,y,z);
}
inline bool qry(int p,int l,int r,int x,int y,int z){
	if(x<=l&&r<=y)return solve(z,S[p]);
	const int mid=(l+r)>>1,ls=p*2,rs=p*2+1;bool t=0;
	if(x<=mid)t|=qry(ls,l,mid,x,y,z);
	if(mid<y)t|=qry(rs,mid+1,r,x,y,z);
	return t;
}
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	freopen("grid.in","r",stdin);
	freopen("grid.out","w",stdout);
	cin>>n>>m>>q,n+=2;
	for(int i=1;i<=q;++i){
		int x,y;cin>>x>>y;
		Q[i]=make_tuple(x,x+2,y,y+2),fd[i]=i;
	}
	build(1,1,n);
	sort(Q+1,Q+q+1,[&](const tuple<int,int,int,int>&x,const tuple<int,int,int,int>&y){return get<3>(x)<get<3>(y);});
	for(int i=1;i<=q;++i){
		auto&[l,r,d,u]=Q[i];
		for(bool o=1;o;){
			o=qry(1,1,n,l,r,i);
			for(int p=pos[l];p;p>>=1)o|=solve(i,T[p]);
			for(int p=pos[r];p;p>>=1)o|=solve(i,T[p]);
		}
		upd(1,1,n,l,r,i);
		for(int p=pos[l];p;p>>=1)S[p].emplace_back(i);
		for(int p=pos[r];p;p>>=1)S[p].emplace_back(i);
	}
	LL ans=0;
	for(int i=1;i<=q;++i)if(find(i)==i){
		const auto [l,r,d,u]=Q[i];
		ans+=(r-l-1ll)*(u-d-1ll);
	}
	return cout<<ans,0;
}
/*
  .
 .*
.**
*/